home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_xemacs.idb / usr / freeware / lib / xemacs-20.4 / lisp / efs / efs-dl.el.z / efs-dl.el
Encoding:
Text File  |  1998-05-21  |  4.5 KB  |  146 lines

  1. ;; -*-Emacs-Lisp-*-
  2. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3. ;;
  4. ;; File:         efs-dl.el
  5. ;; Release:      $efs release: 1.15 $
  6. ;; Version:      #Revision: 1.3 $
  7. ;; RCS:          
  8. ;; Description:  Unix descriptive listing support for efs
  9. ;; Author:       Sandy Rutherford <sandy@tsmi19.sissa.it>
  10. ;; Created:      Wed Jan 13 19:19:20 1993 by sandy on ibm550
  11. ;; Modified:     Sun Nov 27 18:29:41 1994 by sandy on gandalf
  12. ;;
  13. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  14.  
  15. ;;; This file is part of efs. See efs.el for copyright
  16. ;;; (it's copylefted) and warrranty (there isn't one) information.
  17.  
  18. (provide 'efs-unix:dl)
  19. (require 'efs)
  20.  
  21. (defconst efs-dl-version
  22.   (concat (substring "$efs release: 1.15 $" 14 -2)
  23.       "/"
  24.       (substring "#Revision: 1.3 $" 11 -2)))
  25.  
  26. ;;;-----------------------------------------------------------------
  27. ;;; Unix descriptive listing (dl) support for efs
  28. ;;;-----------------------------------------------------------------
  29.  
  30. ;; this is also defined in efs.el, because it used to recognize
  31. ;; a dl listing. We re-define it here just to keep the dl stuff self-contained.
  32.  
  33. (defconst efs-unix:dl-listing-regexp
  34.   "^[^ \n\t]+\n? +\\([0-9]+\\|-\\|=\\) ")
  35.  
  36. ;; entry point
  37.  
  38. (efs-defun  efs-parse-listing unix:dl
  39.   (host user dir path &optional switches)
  40.   ;; Parse the current buffer, which is assumed to be a unix descriptive
  41.   ;; listing, and return a hashtable.
  42.   ;; HOST = remote host name
  43.   ;; USER = user name
  44.   ;; DIR = directory in as a full remote path
  45.   ;; PATH = directory in full efs path syntax
  46.   ;; SWITCHES = ls switches (not relevant here)
  47.   (goto-char (point-min))
  48.   ;; Is it really a listing?
  49.   (efs-save-match-data
  50.     (if (re-search-forward efs-unix:dl-listing-regexp nil t)
  51.     (let ((tbl (efs-make-hashtable)))
  52.       (goto-char (point-min))
  53.       (while (not (eobp))
  54.         (efs-put-hash-entry
  55.          (buffer-substring (point)
  56.                    (progn
  57.                  (skip-chars-forward "^ /\n")
  58.                  (point)))
  59.          (list (eq (following-char) ?/))
  60.          tbl)
  61.         (forward-line 1))
  62.       (efs-put-hash-entry "." '(t) tbl)
  63.       (efs-put-hash-entry ".." '(t) tbl)
  64.       tbl))))
  65.  
  66. ;;; Support for tree dired.
  67.  
  68. (defconst efs-dired-dl-re-dir
  69.   "^. [^ /]+/[ \n]"
  70.   "Regular expression to use to search for dl directories.")
  71.  
  72. (or (assq 'unix:dl efs-dired-re-dir-alist)
  73.     (setq efs-dired-re-dir-alist
  74.       (cons (cons 'unix:dl  efs-dired-dl-re-dir)
  75.         efs-dired-re-dir-alist)))
  76.  
  77.  
  78. (efs-defun efs-dired-manual-move-to-filename unix:dl
  79.   (&optional raise-error bol eol)
  80.   ;; In dired, move to the first character of the filename on this line.
  81.   ;; This is the Unix dl version.
  82.   (or eol (setq eol (save-excursion (skip-chars-forward "^\n\r") (point))))
  83.   (let (case-fold-search)
  84.     (if bol
  85.     (goto-char bol)
  86.       (skip-chars-backward "^\n\r")
  87.       (setq bol (point)))
  88.     (if (and
  89.      (> (- eol bol) 3)
  90.      (progn
  91.        (forward-char 2)
  92.        (skip-chars-forward " \t")
  93.        (looking-at "[^ \n\t]+\n? +\\([0-9]+\\|-\\|=\\) ")))
  94.     (point)
  95.       (goto-char bol)
  96.       (and raise-error (error "No file on this line")))))
  97.  
  98. (efs-defun efs-dired-manual-move-to-end-of-filename unix:dl
  99.   (&optional no-error bol eol)
  100.   ;; Assumes point is at beginning of filename.
  101.   ;; So, it should be called only after (dired-move-to-filename t).
  102.   ;; On failure, signals an error or returns nil.
  103.   ;; This is the Unix dl version.
  104.   (let ((opoint (point)))
  105.     (and selective-display
  106.      (null no-error)
  107.      (eq (char-after
  108.           (1- (or bol (save-excursion
  109.                 (skip-chars-backward "^\r\n")
  110.                 (point)))))
  111.          ?\r)
  112.      ;; File is hidden or omitted.
  113.      (cond
  114.       ((dired-subdir-hidden-p (dired-current-directory))
  115.        (error
  116.         (substitute-command-keys
  117.          "File line is hidden. Type \\[dired-hide-subdir] to unhide.")))
  118.       ((error
  119.         (substitute-command-keys
  120.          "File line is omitted. Type \\[dired-omit-toggle] to un-omit."
  121.          )))))
  122.     (skip-chars-forward "^ /\r\n\t")
  123.     (if (or (= opoint (point)) (not (memq (following-char) '(?\  ?/))))
  124.     (if no-error
  125.         nil
  126.       (error "No file on this line"))
  127.       (point))))
  128.  
  129. (efs-defun efs-dired-insert-headerline unix:dl (dir)
  130.   ;; Unix dl has no total line, so we insert a blank line for
  131.   ;; aesthetics.
  132.   (insert "\n")
  133.   (forward-char -1)
  134.   (efs-real-dired-insert-headerline dir))
  135.  
  136. (efs-defun efs-dired-fixup-listing unix:dl (file path &optional
  137.                          switches wildcard)
  138.   ;; Deal with continuation lines.
  139.   (efs-save-match-data
  140.     (goto-char (point-min))
  141.     (while (re-search-forward "\n +" nil t)
  142.       (delete-region (match-beginning 0) (match-end 0))
  143.       (insert " "))))
  144.  
  145. ;;; end of efs-dl.el
  146.